package urine;

import java.io.IOException;
import java.util.*;
public class BadDog
{
	private int dogX,dogY,fakedogY,whichDog,panelX,panelY;
	private Random randomGenerator;

	/**
	 * lone constructor
	 */
	public BadDog(int x1,int y1) throws IOException
	{
		randomGenerator = new Random();
		dogX=randomGenerator.nextInt(x1);
		dogY=randomGenerator.nextInt(y1);
		whichDog=1;
		panelX=x1;
		panelY=y1;
	}
	/**
	 * moves the dog to a random hole
	 */
	public void moveDog()
	{
		whichDog=randomGenerator.nextInt(2);
		dogX = randomGenerator.nextInt( panelX );
		fakedogY=randomGenerator.nextInt( panelY );
		while(fakedogY<95)	// keep dogs from being drawn on top of pony
		{
			fakedogY=randomGenerator.nextInt( panelY );
		}
		dogY = fakedogY;

	} // end method move
	
	/**
	 * gets dog's X coordinate
	 */
	public int getDogX()
	{
		return dogX;
	}
	
	/**
	 * gets dog's Y coordinate
	 */
	public int getDogY()
	{
		return dogY;
	}
	
	/**
	 * determines if we should draw
	 * a brown dog or a black dog
	 * 0=brown
	 * 1=black
	 */
	public int whichDog()
	{
		return whichDog;
	}

	/**
	 * checks if the dog has been urinated on
	 * 
	 * @param	mouseX
	 * @return	true or false
	 */
	public boolean isHit(int mouseX)
	{
		if ( Math.abs(dogX+15-mouseX)<=50)
		{
			return true;
		}
		else // user missed hitting the dog
		{
			return false;
		}

	} // end method isHit

} // end class BadDog